//
//  YCCollectionViewCell.swift
//  YCCamera
//
//  Created by Billy on 2024/5/16.
//

import UIKit

class YCCollectionViewCell: UICollectionViewCell {
    
    static let imageSize: CGSize = CGSize(width: 300, height: 300)
    
    lazy var imageView: UIImageView = {
        let imageView = UIImageView()
        imageView.frame = self.contentView.bounds
        imageView.contentMode = .scaleAspectFill
        imageView.clipsToBounds = true
        imageView.image = UIImage(named: "defaultImage")

        return imageView
    }()
    
    public var identifier: String? {
        didSet {
            AMPhotoManager.asyncRequestImage(identifier: identifier! as String, targetSize: YCCollectionViewCell.imageSize) { image in
                self.imageView.image = image
            }
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        contentView.addSubview(imageView)
    }
    
    @available(*, unavailable)
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
